using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BUS;

namespace QuanLyThuVien_Nhom23
{
    public partial class frmDangNhap : Form
    {
        DocGiaBUS bus = new DocGiaBUS();
        public static String _MaDocGia;//dung de lay su dung cho lop khac        
        public frmDangNhap()
        {
            InitializeComponent();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            txtPassWord.Text = "";
            txtUserName.Text = "";
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (bus.KiemTraDangNhap(txtUserName.Text, txtPassWord.Text))
            {
                MessageBox.Show("Dang nhap thanh cong");
                Program.user = true;
                _MaDocGia = txtUserName.Text;
                this.Close();                
            }
        }

        private void label4_Click(object sender, EventArgs e)
        {
            this.Close();
            frmCapTheDocGia frm = new frmCapTheDocGia();
            frm.Show();

        }

        private void txtPassWord_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (bus.KiemTraDangNhap(txtUserName.Text, txtPassWord.Text))
                {
                    MessageBox.Show("Dang nhap thanh cong");
                    Program.user = true;
                    _MaDocGia = txtUserName.Text;
                    this.DialogResult = DialogResult.OK;
                    Dispose();
                }
            }
        }
    }
}